package com.example.util;

public class MathUtils {

	public static long bytesToLong(byte[] buff, int start, int length){
		long unit = 1;
		long result = 0;
		for(int i=start+length-1;i>=start;i--){
			result += ( ((char)buff[i]) & (char)0xff ) * unit;
			unit = unit<<8;
		}
		return result;
	}
	
	public static int bytesToInt(byte[] buff, int start, int length){
		int unit = 1;
		int result = 0;
		for(int i=start+length-1;i>=start;i--){
			result += ( ((char)buff[i]) & (char)0xff ) * unit;
			unit = unit<<8;
		}
		return result;
	}
	
	
}
